//MyAccount Form validations
//var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var members="";
function myAccountForm(){
    var charactervalidation = /^[a-zA-Z\s]*$/;
	var flag=true;
	var userName=$('#inputUser').val();
	var email=$('#inputEmail').val();
	var phone=$('#inputPh').val();
	var Alterphone=$('#alterphone').val();
	var address=$('#txtArea').val();
	var location=$('#location').val();
	var pincode=$('#pincode').val();
	var hid=$('#hid').val();
	/*var fax=$('#fax').val();
	var city=$('#city').val();
	var country=$('#country').val();
	var state=$('#state').val();
	*/
	if(userName==""){
		$('#userNameError').html(Account_page_user_name);
		flag=false;
	}else if(!userName.match(charactervalidation)){
	    $('#userNameError').html(Account_page_charactervalidation);
		flag=false;
	}else{
		$('#userNameError').html('');
	}
	
	if(email==""){
	   $("#emailError").html(Account_page_email);
	   flag=false;   
	}else{
	    if(validateEmail(email)==0){
		  $("#emailError").html(Account_page_erroremail);
		  flag=false; 
	    }else{
			  $("#emailError").html(""); 
			}
	} 
	if(phone==""){
		$('#phoneNumberError').html(Account_page_phonenumber);
		flag=false;
	}else if(isNaN(phone)){
		  $('#phoneNumberError').html(Account_page_numbervalidation);
		  flag=false;
	}else{
		$('#phoneNumberError').html('');
	}
	
	if(Alterphone==""){
	   $("#erroralterphone").html(Account_page_alterphonenumber);
	   flag=false;   
	}else if(isNaN(Alterphone)){
	   $("#erroralterphone").html(Account_page_numbervalidation);
	   flag=false;   
	}else{
	  $("#erroralterphone").html("");
	}
	
	if(location==""){
		$('#errorLocation').html(Account_page_location );
		flag=false;
	}else{
		$('#errorLocation').html('');
	}
	
	if(address==""){
		$('#addressError').html(Account_page_address);
		flag=false;
	}else{
		$('#addressError').html('');
	}
	
	if(pincode==""){
		$('#errorPincode').html(Account_page_pincode);
		flag=false;
	}else if(isNaN(pincode)){
	   $("#errorPincode").html(Register_page_numbervalidation);
	   flag=false;
	}else{
		$('#errorPincode').html('');
	}
	/*if(fax==""){
		$('#errorFax').html('Required fax');
		flag=false;
	}else{
		$('#errorFax').html('');
	}	
	if(city==""){
		$('#errorCity').html('Required city');
		flag=false;
	}else{
		$('#errorCity').html('');
	}
	if(country==""){
		$('#errorcountry').html('Required country');
		flag=false;
	}else{
		$('#errorcountry').html('');
	}
	if(state==""){
		$('#errorstate').html('Required state');
		flag=false;
	}else{
		$('#errorstate').html('');
	}*/
	if(flag==true){
		$('#accountReload').html('<img src="images/ajax-loader.gif"/>');
		$.ajax({
			type		:	'PUT',
			url			:  	webServiceUrl+'registration/'+hid,
			dataType	: 	"json",
			data		:	$('#accountForm1').serialize(),
			success: function(data){
				$('#accountReload').html('');
				if(data.value==1){
					$('updatePhone').html('Ph:&nbsp;'+phone);
					$('updateLocation').html(location);
					sessionStorage.setItem( 'phone', JSON.stringify(phone) );
					sessionStorage.setItem( 'location', JSON.stringify(location) );
					$('#success_alert').show();
					$('#sucessDiv').html(Account_page_success_message);
					$("html, body").animate({ scrollTop: 0 }, 600);
					$('#success_alert').delay(3000).fadeOut('slow');
				}else{
					$('#sucessDiv').html('');
				}
			}
		});
	}
}
//login Form validations
function loginForm(){
	var flag=true;
	var userName=$('#username').val();
	var password=$('#password').val();
	if(userName==""){
	   $("#usernameError").html(Login_user_email);
	   flag=false;   
	}else{
	    if(validateEmail(userName)==0){
		  $("#usernameError").html(Login_user_erroremail);
		  flag=false; 
	    }else{
			  $("#usernameError").html(""); 
		}
	}
	
	if(password==""){
		$('#pwdError').html(Login_user_password);
		flag=false;
	}else{
		$('#pwdError').html('');
	}
	
	if(flag==true){
		$('#reload').html('<img src="images/ajax-loader.gif"/>');
		$.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'login',
			dataType	: 	"json",
			data		:	{
								email:userName,pwd:password,user_type_id:'2'
							},
			success: function(data){
				$('#reload').html('');
				 if(data.value==1){
					var obj = eval("(" + data.UserDetails + ")");
					$.each(obj, function (index,Object) {
						var user_id		=	Object.user_id;
						var email		=	Object.email;
						var user_name	=	Object.user_name;
						var phone		=	Object.phone;
						var location	=	Object.location;
						sessionStorage.setItem( 'user_id', JSON.stringify(user_id) );		
						sessionStorage.setItem( 'email', JSON.stringify(email) );
						sessionStorage.setItem( 'user_name', JSON.stringify(user_name) );
						sessionStorage.setItem( 'phone', JSON.stringify(phone) );
						sessionStorage.setItem( 'location', JSON.stringify(location) );
					});
					window.location="account.html";
				}else{
					$('#logsucess').html(Login_error_message);
				}
			}
		});
	}
}
//Forget Password Form validations
function forgetForm(){
    var flag=true;
	var email=$('#inputuser').val();
	
	if(email==""){
	   $("#forgetMailError").html(Forgotpassword_email);
	   flag=false;   
	}else{
	    if(validateEmail(email)==0){
		  $("#forgetMailError").html(Forgotpassword_error_email);
		  flag=false; 
	    }else{
			  $("#forgetMailError").html(""); 
			}
	}
	
	if(flag==true){
	   $('#forgetReload').html('<img src="images/ajax-loader.gif"/>');
	   $.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'forgetpassword',
			dataType	: 	"json",
			data		:	{
								email:email,type:2
							},
			success: function(data){
			$('#forgetReload').html('');
				if(data.value==1){
					$('#successfpassword').html(Forgotpassword_success_message);
				}else{
					$('#successfpassword').html(Forgotpassword_error_message);
				}
			}
		});
	}
}
//Registration Form Validation

function userRegister(){
emailValidation();
var flag=true;
var charactervalidation = /^[a-zA-Z\s]*$/;
var Firstname=$("#inputFirstname").val();
var Email=$("#inputEmail").val();
var Phonenumber=$("#inputTelephone").val();
var Alterphone=$("#alterphone").val();
var Landmark=$("#landmark").val();
var Location=$("#location").val();
var Address=$("#inputAddress").val();
var Pincode=$("#pincode").val();
var Password=$("#password").val();
var Conformpassword=$("#ConformPassword").val();
/*var Lastname=$("#inputLastname").val();
var Fax=$("#fax").val();
var City=$("#city").val();
var Country=$("#country").val();
var State=$("#state").val();*/
	
	if(Firstname==""){
	   $("#errorFirstname").html(Register_page_firstname);
	   flag=false;   
	}else if(!Firstname.match(charactervalidation)){
	   $("#errorFirstname").html(Register_page_charactervalidation);
	   flag=false;
	}else{
	  $("#errorFirstname").html("");
	}
	
	if(Email==""){
	   $("#errorEmail").html(Register_page_email);
	   flag=false;   
	}else{
	    if(validateEmail(Email)==0){
		  $("#errorEmail").html(Register_page_erroremail);
		  flag=false; 
	    }
		else if($('#hidemailerror').val()=='1'){
			$('#errorEmail').html(Register_page_checkerroremail);
			flag=false;
		}else{
			  $("#errorEmail").html(""); 
			}
	}
	
	if(Phonenumber==""){
	   $("#errorTelephonenumber").html(Register_page_phonenumber);
	   flag=false;   
	}else if(isNaN(Phonenumber)){
	   $("#errorTelephonenumber").html(Register_page_numbervalidation);
	   flag=false;   
	}else{
	  $("#errorTelephonenumber").html("");
	}
	
	if(Alterphone==""){
	   $("#erroralterphone").html(Register_page_alternumber);
	   flag=false;   
	}else if(isNaN(Alterphone)){
	   $("#erroralterphone").html(Register_page_numbervalidation);
	   flag=false;   
	}else{
	  $("#erroralterphone").html("");
	}
	if(Landmark==""){
		$("#errorlandmark").html(Register_page_landmark);
	   flag=false;
	}else{
		$("#errorlandmark").html("");
	} 
	
	if(Location==""){
	   $("#errorlocation").html(Register_page_location);
	   flag=false;   
	}else{
	  $("#errorlocation").html("");
	}
	
	if(Address==""){
	   $("#errorAddress").html(Register_page_address);
	   flag=false;   
	}else{
	  $("#errorAddress").html("");
	}
	
	if(Pincode==""){
	   $("#errorpincode").html(Register_page_pincode);
	   flag=false;   
	}else if(isNaN(Pincode)){
	   $("#errorpincode").html(Register_page_numbervalidation);
	   flag=false;
	}else{
	  $("#errorpincode").html("");
	}
	if(Password==""){
	   $("#errorpassword").html(Register_page_password);
	   flag=false;   
	}else{
	  $("#errorpassword").html("");
	}
	if(Conformpassword==""){
	   $("#errorCPassword").html(Register_page_confirmpassword);
	   flag=false;   
	}else if(Password!=Conformpassword){
	   $("#errorCPassword").html(Register_page_errorconfirmpassword);
	   flag=false;
	}else{
	  $("#errorCPassword").html("");
	}
	
	/*if(Lastname==""){
	   $("#errorLastname").html(Register_page_lastname);
	   flag=false;   
	}else if(!Lastname.match(charactervalidation)){
	   $("#errorLastname").html(Register_page_charactervalidation);
	   flag=false;
	}else{
	  $("#errorLastname").html("");
	}
	if(Fax==""){
	   $("#errorfax").html("Required fax");
	   flag=false;   
	}else if(isNaN(Fax)){
	 $("#errorfax").html("Numbers only");
	   flag=false;
	}else{
	  $("#errorfax").html("");
	}
	if(City==""){
	   $("#errorcity").html("Required city");
	   flag=false;   
	}else{
	  $("#errorcity").html("");
	}
	if(Country==""){
	   $("#errorcountry").html("Required country");
	   flag=false;   
	}else{
	  $("#errorcountry").html("");
	}
	//alert(State);return false;
	if(State==""){
	   $("#errorstate").html("Required state");
	   flag=false;   
	}else{
	  $("#errorstate").html("");
	}
	if(Registration.privacy.checked==false){
	   $("#errorCheckbox").html("Required privacy policy");
	   flag=false;
	}else{
	   $("#errorCheckbox").html("");
	}*/
	if(flag==true){
		  
		/*if($('input[name=optionsRadios]:checked').val()==1){
			$.ajax({
				type		:	'POST',
				url			:  	webServiceUrl+'subscriber',
				dataType	: 	"json",
				data		:	{email:Email},
				success: function(data){
					if(data.value==1){
						$('#successSubcription').html('Your successfully subscribed');
					}else{
						$('#successSubcription').html('Your already subscribed user');
					}
				}
			});
		}*/
		$('#registerReload').html('<img src="images/ajax-loader.gif"/>');
		$.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'registration',
			dataType	: 	"json",
			data		:	$('#Registration').serialize(),
			success: function(data){
				$('#registerReload').html('');
				if(data.value==1){
					var user_id		=	data.UserId;
					var email		=	Email;
					var user_name	=	Firstname;
					var phoneL		=	Phonenumber;
					var locationL	=	Location;
					sessionStorage.setItem( 'user_id', JSON.stringify(user_id) );	
					sessionStorage.setItem( 'email', JSON.stringify(email) );
					sessionStorage.setItem( 'user_name', JSON.stringify(user_name) );						
					sessionStorage.setItem( 'phone', JSON.stringify(phoneL) );						
					sessionStorage.setItem( 'location', JSON.stringify(locationL) );						
					window.location="registration-confirm.html";
				}
			}
		});
	}
	
}
//Email validation server side
function emailValidation(){
	var emailcheck=$('#inputEmail').val();
	if(emailcheck!==''){
		if(validateEmail(emailcheck)=='0')
		{
			$('#errorEmail').html(sever_error_email);		
		}else{	
			$.ajax({
				type		:	'GET',
				url			:  	webServiceUrl+'login/'+emailcheck,
				dataType	: 	"json",
				success: function(data){
					if(data.value==1){
						$('#hidemailerror').val('1');
						$('#errorEmail').html(server_check_email);
						return 1;
					}else{
						$('#hidemailerror').val('0');
						$('#errorEmail').html("");
						return 0;
					}
				}
			});
		}
  }
}

// Change Password
function changePassword(){
   var flag=true;
   var Oldpassword=$("#oldpassword").val();
   var Newpassword=$("#newPassword").val();
   var Confirmpassword=$("#Confirmpassword").val();
	if(Oldpassword==""){
      $("#errorOldpassword").html(Change_old_password);
	  flag=false;
	}else{
      $("#errorOldpassword").html("");
	}
	
	if(Newpassword==""){
      $("#errorNewpassword").html(Change_new_password);
	  flag=false;
	}else{
      $("#errorNewpassword").html("");
	}
	
	if(Confirmpassword==""){
        $("#errorConfirmpassword").html(Change_confirm_password);
		flag=false;
	}else if(Newpassword!=Confirmpassword){
	   $("#errorConfirmpassword").html(Change_errorconfirm_password);
	   flag=false;
	}else{
       $("#errorConfirmpassword").html("");
	}
	
	if(flag==true){
		$('#changePasswordReload').html('<img src="images/ajax-loader.gif"/>');
		var user_id = JSON.parse(sessionStorage["user_id"]);
        $.ajax({
				type		:	'PUT',
				url			:  	webServiceUrl+'changepassword/'+user_id,
				dataType	: 	"json",
				data        : {old_password:Oldpassword,cnf_password:Confirmpassword},
				success: function(data){
					$('#changePasswordReload').html('');
					
					if(data.value==1){
						$('#success_alert').show();
						$('#errorCpassword').html(Change_successpassword_message);
						$("html, body").animate({ scrollTop: 0 }, 600);
						$('#success_alert').delay(3000).fadeOut('slow');
						$('#error_alert').hide();
						$("#oldpassword").val('');
					    $("#newPassword").val('');
						$("#Confirmpassword").val('');
					}else{
						$('#error_alert').show();
						$('#errorCpasswordError').html(Changepassword_error_message);
						$("html, body").animate({ scrollTop: 0 }, 600);
						//$('#error_alert').delay(3000).fadeOut('slow');
					}
				}
		});
	}
}

//Reset password
function passwordReset(){
  var flag=true;
  var Resetpassword=$("#resetPassword").val();
  var Confirmpassword=$("#Confirmpassword").val();
    if(Resetpassword==""){
      $("#errorResetpassword").html(Reset_newpassword);
	  flag=false;
	}else{
      $("#errorResetpassword").html("");
	}
	
	if(Confirmpassword==""){
        $("#errorConfirmpassword").html(Reset_confirm_password);
		flag=false;
	}else if(Resetpassword!=Confirmpassword){
	   $("#errorConfirmpassword").html(Resetpassword_confirm_errormessage);
	   flag=false;
	}else{
       $("#errorConfirmpassword").html("");
	}
	
	if(flag==true){
	   var path = window.location.href;
	   path = path.replace(/\/$/, "");
	   path = decodeURIComponent(path);
       var id=path.split('=');
       var token=id[1];
	   $('#resetPasswordReload').html('<img src="images/ajax-loader.gif"/>');
	    $.ajax({
				type		:	'PUT',
				url			:  	webServiceUrl+'forgetpassword/'+token,
				dataType	: 	"json",
				data        : {cnf_password:Confirmpassword},
				success: function(data){
					$('#resetPasswordReload').html('');
					if(data.value==1){
						$('#success_alert').show();
						$('#errorSuccess').html(Resetpassword_success_message);
						$("html, body").animate({ scrollTop: 0 }, 600);
						$('#success_alert').delay(3000).fadeOut('slow');
						$('#error_alert').hide();
					}else{
						$('#errorSuccessError').html(Resetpassword_error_message);
					}
				}
		});
	}
}
function logoutFunction(){
	sessionStorage.removeItem("user_id");
	sessionStorage.removeItem("email");
	sessionStorage.removeItem("user_type");
	window.location="index.html";
}
function subscribe(){
	var flag=true;  
	var Email=$('#subscribe').val();
	if(Email==""){
	   $("#errorEmail").html(Register_page_email);
	   flag=false;   
	}else{
	    if(validateEmail(Email)==0){
		  $("#errorEmail").html(Register_page_erroremail);
		  flag=false; 
	    }
	}
	if(flag==true){
		$.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'subscriber',
			dataType	: 	"json",
			data		:	{email:Email},
			success: function(data){
				if(data.value==1){
					$('#errorEmail').html('Your successfully subscribed');
					$('#subscribe').val("");
				}else{
					$('#errorEmail').html('Your already subscribed user');
				}
			}
		});
	}
}


//get state values list

function getstateValues(){

  var country=$("#country").val();
   $.ajax({
				type		:	'POST',
				url			:  	webServiceUrl+'state',
				dataType	: 	"json",
				data        : {countryId:country},
				success: function(data){
					var statedetailes;
					if(data.value==0){
						statedetailes +='<option value="">Select state</option>';
					}else{
					    var obj = eval("(" + data.data + ")");
						if(typeof sessionStorage["user_id"]=='undefined'){
							
							$.each(obj, function (index,Object) {
								statedetailes +='<option  value="'+Object.state_id+'">'+Object.state_name+'</option>';
							});
						}else{
						  $.each(obj, function (index,Object) {
						             var user_state=$("#hidstate").val();
									if(user_state==Object.state_id){
									   statedetailes +='<option  selected value="'+Object.state_id+'">'+Object.state_name+'</option>';
									}else{
									   statedetailes +='<option  value="'+Object.state_id+'">'+Object.state_name+'</option>';
									}
								});
						}
					}
					$('#state').html(statedetailes);
				}
		});
}
function reOrderDetailes(track_id){
  window.location=window.location="orderonline.html?ID="+track_id;
}
function reorderOnline(track_id){
	$.ajax({
		type		:	'GET',
		url			:  	webServiceUrl+'order/singleorder-'+track_id,
		dataType	: 	"json",
		success: function(data){
			if(data.value==1){
			    var html="";
				var Immediate="";
				var pre_images="";
				var obj = eval("(" + data.data + ")");
				$.each(obj, function (index,Object) {
					$('#inputuser').val(Object.user_name);
					$('#inputEmail').val(Object.email);
					$('#inputLm').val(Object.landmark);
					$('#txtArea').val(Object.address);
					$('#inputPh').val(Object.phone);
					$('#alterinputPh').val(Object.alterphone);
					$('#hidImages').val(Object.prescription_upload_path);
					var prescription_images=Object.prescription_upload_path;
						var p_images=prescription_images.split('**');
						if(p_images.length>0){
							for(var i=0;i<=(p_images.length-1);i++){
								if(p_images[i]!=null){	
									var Imagenumber=p_images[i].split('.');
									if(Imagenumber==""){
										pre_images+="";
									}else{
										pre_images+='<div id="image'+Imagenumber[0]+'" style="display:inline"><img src="'+uploadImgUrl+p_images[i]+'" width="50px" height="50px"/>'+'/'+'<a href=javascript:void(0); onclick="DeleteImage('+Imagenumber[0]+')">Delete</a>'+
										'<input type="hidden" name="hid_type'+Imagenumber[0]+'" id="hid_type'+Imagenumber[0]+'" value="'+Imagenumber[1]+'"></div>';
									}
								}
							}							
						}
					var pre_detailes=Object.prescription_details;
					var pdetailes=pre_detailes.split('**');
						for(var i=0;i<=(pdetailes.length-1);i++){
							var names=pdetailes[i].split('$$');
							var tabletName=names[0];
							var quantity=names[1];
							if(i==0){
							   html+= '<input type="text" class="span4" id="tabletName" name="tabletName[]" value='+tabletName+'>'+
								'<input type="number" class="span2" id="quantity" name="quantity[]" value='+quantity+'>'+
								'<a href="javascript:void(0);" id="btn252" class="addmore" onclick="add()">Add Another</a>'+
								'<span id="add1"></span>';
								$('#reorder_tablets_div').html(html);
							}else{
							     $("#add1").append('<div id="removediv'+(i+1)+'" class="fileremove"><input type="text" class="span4" name="tabletName[]" id="tabletName" value='+tabletName+'><input type="number" class="span2" name="quantity[]" id="quantity" value='+quantity+'><a href="javascript:void(0)" id="remove" class="delete" onclick="removediv1('+(i+1)+');"> Delete </a></div>');
							}
							html="";
							$('#countFileReorder').val(i+2);
						}
					var auto_renewal=Object.auto_renewal;
						if(auto_renewal==0 || auto_renewal==null){
						  $("#autoRenewal0").prop("checked", true);											  
						}else{
						  $("#autoRenewal1").prop("checked", true);
						  $('#eachDays').val(Object.each_days);
						}
					var Immediate=Object.immediate;
						if(Immediate==1){
						 $("#Timings1").prop("checked", true);
						    $('#availableRadio').hide();
							$('#available_time').val("");
							
						}else{
						  $("#Timings0").prop("checked", true);
						  $('#availableRadio').show();
						  $('#available_time').val(Object.availabletime);
						}
				});
				$("#Display_images").html(pre_images);				
			}
		}
	});

}


//delete images
function DeleteImage(image){
var hid_images=$('#hidImages').val();
var hid_type=$('#hid_type'+image).val();
	if (hid_images.indexOf(image+'.'+hid_type+'**') >= 0){
		var new_hid_images=hid_images.replace(image+'.'+hid_type+'**','');
	}else if(hid_images.indexOf('**'+image+'.'+hid_type)>= 0){
		var new_hid_images=hid_images.replace('**'+image+'.'+hid_type,'');
	}else{
		var new_hid_images=hid_images.replace(image+'.'+hid_type,'');
	}
	$('#image'+image).remove();
	$('#hidImages').val(new_hid_images);
	var hid_images=$('#hidImages').val();
}
//CancelOrder in order history
 function cancelOrder(tracking_id){
    var Cancelledorder_tracking_id=tracking_id;
	$.ajax({
				type		:	'PUT',
				url			:  	webServiceUrl+'order/'+Cancelledorder_tracking_id,
				dataType	: 	"json",
				success: function(data){
					if(data.value==1){
					    window.location="orderhistory.html?status=cancelled";
					}
				}
		    });
}

// Order online page
function sendOrder(){
	var vvalue=0;
	var value=0;
	var flag=true;
	var Timepattern = /^([0-1][0-9]\:[0-1][0-9]*[ap]m)\-[0-1][0-9]\:[0-1][0-9]*[ap]m$/;
	var Landmark=$("#inputLm").val();
	var Alter_phone=$("#alterinputPh").val();
	var phone=$('#inputPh').val();
	var Address=$('#txtArea').val();
	if(Landmark==""){
	   	$('#errorlandmark').html(sendorder_landmark);
		flag=false;
	}else{
	   $('#errorlandmark').html('');
	}
	if(phone==""){
		$('#phoneNumberError').html(Account_page_phonenumber);
		flag=false;
	}else if(isNaN(phone)){
	    $('#phoneNumberError').html(Account_page_numbervalidation);
		flag=false;
	}else{
		$('#phoneNumberError').html('');
	}
	
	if(Address==""){
	   $("#errorAddress").html(Register_page_address);
	   flag=false;   
	}else{
	  $("#errorAddress").html("");
	}
	
	/*if(Alter_phone==""){
	   $("#errorAlterphone").html(order_Alter_phonenumber);
	   flag=false;
	}else*/

	if(isNaN(Alter_phone)){
	    $("#errorAlterphone").html(Alter_errorphone);
		flag=false;
	}else{
	   $("#errorAlterphone").html('');
	}
	
	$('input[name="tabletName[]"]').each(function() {
		if ($.trim(this.value) == '') {
			value=1;
			flag=false;
		}
	});
	$('input[type="number"]').each(function() {
		if ($.trim(this.value) == '') {
			vvalue=3;
			flag=false;
		}else if($.trim(this.value) <=0){
			vvalue=2;
			flag=false;
		}
	});
	if(value==1){
		$('#textboxes').html(Order_page_manualfields);
	}else{
		$('#textboxes').html('');
	}
	if(vvalue==2 || vvalue==3){
		$('#textboxess').html(Order_page_integervalidation);
	}else{
		$('#textboxess').html('');
	}
	if(!$('#autoRenewal').is(':checked')){
		if(typeof $('input[name=autoRenewal]:checked', '#orderForm').val()=="undefined"){
			$('#autoRenewalError').html(Order_page_autorenewal);
			flag=false;
		}else{
			$('#autoRenewalError').html('');
		}
	}else{
		$('#autoRenewalError').html('');
	}
	if($('input[name=autoRenewal]:checked', '#orderForm').val()==1){
		if($('#eachDays').val()==""){
			$('#eachDaysError').html(Order_page_days);
			flag=false;
		}else if(isNaN($('#eachDays').val())){
			$('#eachDaysError').html(Alter_errorphone);
			flag=false;
		}else{
			$('#eachDaysError').html('');
		}
	}
	if(!$('#Timings').is(':checked')){
		if(typeof $('input[name=Timings]:checked', '#orderForm').val()=="undefined"){
			$('#timigsError').html(Order_page_timings);
			flag=false;
		}else{
			$('#timigsError').html('');
		}
	}else{
		    $('#timigsError').html('');
	}
	if($('input[name=Timings]:checked', '#orderForm').val()==0){
		if($('#available_time').val()==""){
		    $('#available_timeError').html(Avialable_time_error_message);
			flag=false;
		}else if(!$('#available_time').val().match(Timepattern)){
			$('#available_timeError').html(Availabletime_pattern_message);
			flag=false;
		}else{
			$('#available_timeError').html('');
		}
	}
	var notification_order=$("#hid_value").val();
	if(flag==true){
		$('#orderOnlineReload').html('<img src="images/ajax-loader.gif"/>');
		$.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'order',
			dataType	: 	"json",
			data		:	$('#orderForm').serialize(),
			success: function(data){
				$('#orderOnlineReload').html('');
				if(data.value==1){
					window.location="user-acknowledgement.html?TID="+data.TrackingId;
				}
			}
		});
	}
}
function removediv(num){
  $("#removediv"+num).remove();
}
function removediv1(num){
  $("#removediv"+num).remove();
}

//Reviews and ratings
function validateReviews(){
    var flag=true;
	var trackId=$("#reviewTrackId").val();
	var ratingValue=$("#hidRating").val();
	var reviewText=$("#textArea").val();
	if(trackId==""){
	   $("#errorReviewTrackId").html(Track_id);
	   flag=false;   
	}else if(isNaN(trackId)){
	   $("#errorReviewTrackId").html(Tracking_id_number);
	   flag=false;   
	}else{
	  $("#errorReviewTrackId").html("");
	}
	if(reviewText==""){
		$("#reviewError").html(Review);
		flag=false;
	}else{
		$("#reviewError").html("");
	}
	if(ratingValue==0){
		$("#ratingError").html(Review_rating);
		flag=false;
	}else{
		$("#ratingError").html("");
	}
	if(flag==true){
		$('#userReviewReload').html('<img src="images/ajax-loader.gif"/>');
		var user_id = JSON.parse(sessionStorage["user_id"]);
		var reviewhtml="";
		$.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'reviews',
			dataType	: 	"json",
			data		:	{user_id:user_id,tracking_id:trackId,rating:ratingValue,review:reviewText,complaint_id:"0",compliantType:"ReviewRating"},
			success: function(data){
				$('#userReviewReload').html('');
				if(data.value==1){
				        $("#reviewTrackId").val('');
						$("#hidRating").val(0);
						reviewhtml+='<a href="javascript:void(0)" onclick="ratingOrder(1)"><img class="star"  src="images/gray-star.png"></a>'+
							'<a href="javascript:void(0)" onclick="ratingOrder(2)"><img class="star" src="images/gray-star.png"></a>'+
							'<a href="javascript:void(0)" onclick="ratingOrder(3)"><img class="star" src="images/gray-star.png"></a>'+
							'<a href="javascript:void(0)" onclick="ratingOrder(4)"><img class="star" src="images/gray-star.png"></a>'+
							'<a href="javascript:void(0)" onclick="ratingOrder(5)"><img class="star" src="images/gray-star.png"></a>';	
						$('#rating').html(reviewhtml);
						$("#textArea").val('');
						$('#success_alert').show();
						$("#Checktracking_id").html(Review_rating_success_message);
						$("html, body").animate({ scrollTop: 0 }, 600);
						$('#success_alert').delay(3000).fadeOut('slow');
						$('#error_alert').hide();
				}else{
						$('#error_alert').show();
						$("#Checktracking_idError").html(Review_rating_validtracking_message);
						$("html, body").animate({ scrollTop: 0 }, 600);
				}
			}
		});	
	}
}

function ratingOrder(value){
	var html="";
	for(var i=1;i<=value;i++){
		html+='<a href="javascript:void(0)" onclick="ratingOrder('+i+')"><img class="star" src="images/green-star.png"></a>';
	}for(var i=value+1;i<=5;i++){
		html+='<a href="javascript:void(0)" onclick="ratingOrder('+i+')"><img class="star" src="images/gray-star.png"></a>';
	}
	html+='<span style="color:red;" id="ratingError" name="ratingError"></span>';
	$('#rating').html(html);
	$('#hidRating').val(value);
}

//Order Status 
function orderStatusValidations(){
    var flag=true;
	var orderTrackId=$("#orderTrackId").val();
	if(orderTrackId==""){
	   $("#errorOrderTrackId").html(Orderstatustrack_id);
	   flag=false;   
	}else if(isNaN(orderTrackId)){
	   $("#errorOrderTrackId").html(Orderstatustracking_id_number);
	   flag=false;   
	}else{
	  $("#errorOrderTrackId").html("");
	}
	if(flag==true){
		$('#orderStatusReload').html('<img src="images/ajax-loader.gif"/>');
	    var user_id = JSON.parse(sessionStorage["user_id"]);
		   $.ajax({
				type		:	'GET',
				url			:  	webServiceUrl+'order/order-'+orderTrackId+'-'+user_id,
				dataType	: 	"json",
				success: function(data){
					$('#orderStatusReload').html('');
					$("#orderTrackId").val('');
					if(data.value==0){
						$('#success_alert').show();
						$("#orderStatusId").html(Orderstatus_pending);
						$("html, body").animate({ scrollTop: 0 }, 600);
						$('#success_alert').delay(3000).fadeOut('slow');
						$('#error_alert').hide();
					}else if(data.value==1){
						$('#success_alert').show();
						$("#orderStatusId").html(Orderstatus_processing);
						$("html, body").animate({ scrollTop: 0 }, 600);
						$('#success_alert').delay(3000).fadeOut('slow');
						$('#error_alert').hide();
					}else if(data.value==2){
						$('#success_alert').show();
						$("#orderStatusId").html(Orderstatus_processed);
						$("html, body").animate({ scrollTop: 0 }, 600);
						$('#success_alert').delay(3000).fadeOut('slow');
						$('#error_alert').hide();
					}else if(data.value==3){
						$('#success_alert').show();
						$("#orderStatusId").html(Orderstatus_cancelled);
						$("html, body").animate({ scrollTop: 0 }, 600);
						$('#success_alert').delay(3000).fadeOut('slow');
						$('#error_alert').hide();
					}else{
						$('#error_alert').show();
						 $("#orderStatusIdError").html(Orderstatus_error_message);
						$("html, body").animate({ scrollTop: 0 }, 600);
					}
				}
			});
	}
}
//User complaints 
function validUserComplaint(){
    var flag=true;
	var complaintTrackId=$("#complaintId").val();
	var userComplaint=$("#textArea").val();
	
	if(complaintTrackId==""){
	   $("#errorComplaintTrackId").html(Complaint_track_id);
	   flag=false;   
	}else if(isNaN(complaintTrackId)){
	   $("#errorComplaintTrackId").html(Complaint_track_id_number);
	   flag=false;   
	}else{
	  $("#errorComplaintTrackId").html("");
	}
	
	if(userComplaint==""){
		$("#complaintError").html(Complaint);
		flag=false;
	}else{
		$("#complaintError").html("");
	}
	if(flag==true){
	    $('#userComplaintReload').html('<img src="images/ajax-loader.gif"/>');
	    var user_id = JSON.parse(sessionStorage["user_id"]);
		$.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'complaints',
			dataType	: 	"json",
			data		:	{user_id:user_id,complaint:userComplaint,tracking_id:complaintTrackId,compliantType:"Complaint",complaint_id:"0"},
			success: function(data){
				$('#userComplaintReload').html('');
				if(data.value==1){
				        $("#complaintId").val("");
	                    $("#textArea").val("");
						$('#error_alert').hide();
						$('#success_alert').show();
						$("#CheckComplaint").html(Complaint_success_message);
						$("html, body").animate({ scrollTop: 0 }, 600);
						$('#success_alert').delay(3000).fadeOut('slow');
				}else{
						$('#error_alert').show();
						$("#CheckComplaintError").html(Complaint_validtracking_message);
						$("html, body").animate({ scrollTop: 0 }, 600);
				}
			}
		});
	
	}
}

//Renewal order
 //cancelled order
function cancelautorenewalFun(tracking_id,autorenuval){
	var user_id = JSON.parse(sessionStorage["user_id"]);
	$.ajax({
		type		:	'PUT',
		url			:  	webServiceUrl+'renuwalorder/'+tracking_id,
		dataType	: 	"json",
		data		:	{tracking_id:tracking_id,auto_renewal:autorenuval,user_id:user_id,hid_value:"ORDER"},
		success: function(data){
			if(data.value==1){
				if(autorenuval==0){
					$('#auto'+tracking_id).html('No');
					var text='Enable autorenewal';
					$('#cancelautorenewal'+tracking_id).html('<a href="javascript:void(0)" onclick="cancelautorenewalFun('+tracking_id+',1)">'+text+'</a>'+'/'+'<a href="#'+tracking_id+'" role="button" class="" data-toggle="modal">View</a>');
				}else{
					$('#auto'+tracking_id).html('Yes');
					var text='Cancel autorenewal';
					$('#cancelautorenewal'+tracking_id).html('<a href="javascript:void(0)" onclick="cancelautorenewalFun('+tracking_id+',0)">'+text+'</a>'+'/'+'<a href="#'+tracking_id+'" role="button" class="" data-toggle="modal">View</a>');
				}
				/*$('#cancelautorenewal'+tracking_id).html('<a href="javascript:void(0)" onclick="cancelautorenewalFun('+tracking_id+',1)">'+text+'</a>'+'/'+'<a href="#'+tracking_id+'" role="button" class="" data-toggle="modal">View</a>');*/
			}
		}
	});
}
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

//Discounts 
//All Compliant list


//Shop registration/
function shopRegister(){
emailValidation();
var flag=true;
var charactervalidation = /^[a-zA-Z\s]*$/;
var Shopname=$("#shopName").val();
var Email=$("#inputEmail").val();
var Phonenumber=$("#inputTelephone").val();
var Alterphone=$("#alterphone").val();
var Location=$("#location").val();
var Address=$("#inputAddress").val();
var Pincode=$("#pincode").val();
var Password=$("#password").val();
var Conformpassword=$("#ConformPassword").val();

	if(Shopname==""){
	   $("#errorshopName").html(Register_shop_name);
	   flag=false;   
	}else if(!Shopname.match(charactervalidation)){
	   $("#errorshopName").html(Register_page_charactervalidation);
	   flag=false;
	}else{
	  $("#errorshopName").html("");
	}
	
	if(Email==""){
	   $("#errorEmail").html(Register_page_email);
	   flag=false;   
	}else{
	    if(validateEmail(Email)==0){
		  $("#errorEmail").html(Register_page_erroremail);
		  flag=false; 
	    }
		else if($('#hidemailerror').val()=='1'){
			$('#errorEmail').html(Register_page_checkerroremail);
			flag=false;
		}else{
			  $("#errorEmail").html(""); 
			}
	}
	
	if(Phonenumber==""){
	   $("#errorTelephonenumber").html(Register_page_phonenumber);
	   flag=false;   
	}else if(isNaN(Phonenumber)){
	   $("#errorTelephonenumber").html(Register_page_numbervalidation);
	   flag=false;   
	}else{
	  $("#errorTelephonenumber").html("");
	}
	
	if(Alterphone==""){
	   $("#erroralterphone").html(Register_page_alternumber);
	   flag=false;   
	}else if(isNaN(Alterphone)){
	   $("#erroralterphone").html(Register_page_numbervalidation);
	   flag=false;   
	}else{
	  $("#erroralterphone").html("");
	}
	
	if(Location==""){
	   $("#errorlocation").html(Register_page_location);
	   flag=false;   
	}else{
	  $("#errorlocation").html("");
	}
	
	if(Address==""){
	   $("#errorAddress").html(Register_page_address);
	   flag=false;   
	}else{
	  $("#errorAddress").html("");
	}
	
	if(Pincode==""){
	   $("#errorpincode").html(Register_page_pincode);
	   flag=false;   
	}else if(isNaN(Pincode)){
	   $("#errorpincode").html(Register_page_numbervalidation);
	   flag=false;
	}else{
	  $("#errorpincode").html("");
	}
	if(Password==""){
	   $("#errorpassword").html(Register_page_password);
	   flag=false;   
	}else{
	  $("#errorpassword").html("");
	}
	if(Conformpassword==""){
	   $("#errorCPassword").html(Register_page_confirmpassword);
	   flag=false;   
	}else if(Password!=Conformpassword){
	   $("#errorCPassword").html(Register_page_errorconfirmpassword);
	   flag=false;
	}else{
	  $("#errorCPassword").html("");
	}
	if(flag==true){
		$('#registerReload').html('<img src="images/ajax-loader.gif"/>');
		$.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'shopregister',
			dataType	: 	"json",
			data		:	$('#shopRegistration').serialize(),
			success: function(data){
				$('#registerReload').html('');
				if(data.value==1){
					$('#success_alert').show();
					$('#Successshopregister').html(Registration_success_message);
					$("html, body").animate({ scrollTop: 0 }, 600);
					$('#success_alert').delay(3000).fadeOut('slow');
				}else{
					$('#Successshopregister').html('');
				}
			}
		});
	}
}

// REQUEST SERVICES

function PreviousFun(num){
var user_id = JSON.parse(sessionStorage["user_id"]);
	$.ajax({
		type		:	'GET',
		url			:  	 webServiceUrl+'nursing-services/'+user_id+'-1'+'-'+num,
		dataType	: 	"json",
		success: function(data){
			if(data.value==1){
				alert(data.count-5);
				$('Previous').html()
			}
		}
	});
}

//nursing services

function RequestserviceFun(){
	var user_id = JSON.parse(sessionStorage["user_id"]);
	$.ajax({
		type		:	'GET',
		url			:  	 webServiceUrl+'nursing-services/'+user_id+'-0',
		dataType	: 	"json",
		success: function(data){
			var html="";
			if(data.value==1){
				html+='<form id="formid">';
				html+='<table id="tableId">';
				/*var obj = eval("(" + data.data + ")");
				$.each(obj, function (index,Object) {
					var nameTest=Object.test_name;
					var name=nameTest.replace(/ /g,'');
					html+=	'<tr>'+
								'<td>'+Object.test_name+'</td>'+
								'<td>:</td>';
								if(Object.price!=0){
								html+='<td><input type="radio" name="'+name+'Test" id="'+name+'Test" value="'+Object.price+'">YES</td>'+
								'<td><input type="radio" name="'+name+'Test" id="'+name+'TEst" value="0">NO</td>';
								}else{
								html+='<td><input type="radio" name="'+name+'Test" id="'+name+'Test" value="1">YES</td>'+
								'<td><input type="radio" name="'+name+'Test" id="'+name+'TEst" value="0">NO</td>';
								}
								html+='<td>Price</td>'+
								'<td>:</td>';
								if(Object.price!=0){
									html+='<td>'+Object.price+'</td>';
								}else{
									html+='<td>Admin Confirm the price after send the request</td>';
								}
							html+='</tr>';
				});*/
				html+='<tr><td>Select Services : <select id="Testname" name="Testname[]" multiple="multiple" onchange="dispalySelectedValues()">';
				//html+='<option value="0" id="select" name="select">Seelct</option>';
				var obj = eval("(" + data.data + ")");
				$.each(obj, function (index,Object) {
					if(Object.price!=""){
					   html+='<option value="'+Object.price+'$$'+Object.test_name+'">'+Object.test_name+'</option>';
					}else{
						 html+='<option>'+Object.test_name+'</option>';
					}
				});
				html+='<select><td><span id="errortestname" name="errortestname" style="color:red"></span></td></tr>';
				html+='<tr id="selectedtests"></tr>';
				html+='<tr id="hidtototalamount" style="display:none"><td>Total Amount:</td><td><input type="text" id="totalamount" name="totalamount" ></td></tr>';
				html+='<tr><td style="color:red" >Do You Have Insurence:</td>';
				html+='<td><input type="radio" name="insurenceyes" id="insurenceyes" value="1" onclick="InsurenceFun()">YES</td>'+
				'<td><input type="radio" name="insurenceyes" id="insurenceyes" value="0" onclick="InsurenceFun()">NO</td><td><span id="insurenceyesError" name="insurenceyesError" style="color:red"></span></td></tr>';
				html+='<tr id="insurenceshowhide" style="display:none"><td>Insurance</td><td>:</td><td>'+'<select id="insurance" name="insurance" onclick="SelectInsurenceFun()">'+
				'<option value="0">Select Insurance</option>'+
				'<option value="Others">others</option>';
				var obj = eval("(" + data.insurances + ")");
				$.each(obj, function (index,Object){
				html+='<option value="'+Object.insurance_id+'">'+Object.insurance_name+'</option>';
				});
				html+='</select></td><td><span id="errorInsurance" name="errorInsurance" style="color:red"></span></td></tr>'; 
				html+='<tr id="polacnumber" style="display:none"><td>policy number</td><td>:</td><td><input type="text" id="pnumber" name="pnumber" ></td><td><span id="pnumberError" name="pnumberError" style="color:red"></span></td></tr>'+
				'<tr style="display:none" id="polacholnumber" ><td>Policy Hoder Name</td><td>:</td><td><input type="text" id="policyhname" name="policyhname" ></td><td><span id="policyhnameError" name="policyhnameError" style="color:red"></span></td></tr>'+
				'<tr style="display:none" id="dependentholder"  ><td>UST Dependent</td><td>:</td><td><input type="text" id="dependent" name="dependent" ></td><td><span id="errordependent" name="errordependent" style="color:red"></span></td></tr>';
				
				
				html+='<tr><td style="color:red;">User Address</td><td></td><td style="text-align:right;"><input type="checkbox" name="checkbox" id="checkbox" onclick=changeuserAddress(); />Change Address</td></tr>';
				var obj = eval("(" + data.userdata + ")");
					$.each(obj, function (index,Object) {	
						html+='<tr id="userdata_empty"><tr><td>Phone Number</td><td>:</td><td><input type="text" id="phone" name="phone" value="'+Object.phone+'"></td><td><span id="phoneNumberError" name="phoneNumberError" style="color:red"></span></td></tr>'+
						'<tr><td>Alternative Phone Number</td><td>:</td><td><input type="text" id="alterPhone" name="alterPhone" value="'+Object.alterphone+'" ></td><td><span id="alterphoneNumberError" name="alterphoneNumberError" style="color:red"></span></td></tr>'+
						'<tr><td>Landmark</td><td>:</td><td><input type="text" id="landmark" name="landmark" value="'+Object.landmark+'" ></td><td><span id="errorlandmark" name="errorlandmark" style="color:red"></span></td></tr>'+
						'<tr><td>Address</td><td>:</td><td><textarea id="address" name="address" ">'+Object.address+'</textarea></td><td><span id="addressError" name="addressError" style="color:red"></span></td></tr>'+
						'<tr><td>Pincode</td><td>:</td><td><input type="text" id="pincode" name="pincode" value="'+Object.pincode+'" ></td><td><span id="errorPincode" name="errorPincode" style="color:red"></span></td></tr></tr>';
					});
				
				html+='</table>'+
				'<div class="control-group">'+
					'<div class="controls">'+
						'<button type="button" class="medicart_btn" onclick="requestServiceValidations()">Send</button><span id="requestServiceReload"></span>'+
					'</div>'+
				'</div>'+
				'<input type="hidden" id="user_id" name="user_id" value="'+user_id+'">'+
				'<input type="hidden" id="type" name="type" value="0">';
				$('#requestServices').html(html);
			html+='</form>';	
			}else{
				$('#requestServices').html("No Tests found!");
			}	
		}
	});
}
function dispalySelectedValues(){
	var selecttest=$('#Testname').val();
	var selecttestname="";	
	var html="";
	$('#selectedtests').html("");
		$('#totalamount').val(0);
		if(selecttest==0){
			alert("please select testname");
			return false;
		}
			for(var i=0; i<selecttest.length; i++){
				selecttestname=selecttest[i].split("$$");
				var selecttest_price=selecttestname[0];
				$('#hidtototalamount').show();
				html+='<td id="removeId'+selecttestname[0]+i+'"><input type="button" value="x" onclick="removeTestFun('+selecttest_price+','+i+')"/><input type="text" name="test[]" id="test'+selecttestname[0]+'" size="3px" width="3px" value="'+selecttestname[1]+'"><input type="hidden"  name="hidtest_name_price[]" id="hidtest_name_price" value="'+selecttestname[1]+'$$'+selecttestname[0]+'"></td>';
				$('#selectedtests').html(html);
				if(selecttest.length==1){
					$('#totalamount').val(selecttest_price);
				}else{
					$('#totalamount').val(parseInt($('#totalamount').val())+parseInt(selecttest_price));
				}
			}
		
	}	
function removeTestFun(test_price,val){	
	var remove_price=parseInt($('#totalamount').val())-parseInt(test_price);
	if(remove_price=='0'){
		$('#hidtototalamount').hide();
	}
	//$("option:selected").prop("selected", false);
	$("#Testname option:selected").removeAttr("selected");
	$('#totalamount').val(remove_price);
	$('#removeId'+test_price+val).remove();
}
function InsurenceFun(){
	if($('input[name=insurenceyes]:checked').val()==1){
		$('#insurenceshowhide').show();
		$('#insurenceyesError').html('');
		$('#errorInsurance').html('');
		$('#pnumberError').html('');
		$('#policyhnameError').html('');
		$('#errordependent').html('');
	}else{
		$('#insurenceyesError').html('');
		$('#insurenceshowhide').hide();
		$('#polacnumber').hide();
		$('#polacholnumber').hide();
		$('#dependentholder').hide();
		$('#insurance').val('0');
		$('#pnumber').val("");
		$('#policyhname').val("");
		$('#dependent').val("");
		
	}
}
function SelectInsurenceFun(){
	if($('#insurance').val()=="Others"){
		$('#errorInsurance').html('');
		$('#polacnumber').show();
		$('#polacholnumber').show();
		$('#dependentholder').show();
		$('#pnumberError').html('');
		$('#policyhnameError').html('');
		$('#errordependent').html('');
	}else{
		$('#polacnumber').hide();
		$('#polacholnumber').hide();
		$('#dependentholder').hide();
		$('#pnumber').val("");
		$('#policyhname').val("");
		$('#dependent').val("");
	}
}
function changeuserAddress(){
		if($('#checkbox').prop('checked')){
			var phone=$('#phone').val("");
			var alterphone=$('#alterPhone').val("");
			var landmark=$('#landmark').val("");
			var address=$('#address').val("");
			var pincode=$('#pincode').val("");
		}else{
			var user_id = JSON.parse(sessionStorage["user_id"]);
			$.ajax({
				type		:	'GET',
				url			:  	 webServiceUrl+'nursing-services/'+user_id+'-0',
				dataType	: 	"json",
				success: function(data){
					var obj = eval("(" + data.userdata + ")");
						$.each(obj, function (index,Object) {
							$('#phone').val(Object.phone);
							$('#alterPhone').val(Object.phone);
							$('#landmark').val(Object.landmark);
							$('#address').val(Object.address);
							$('#pincode').val(Object.pincode);
							$('#phoneNumberError').html("");
							$('#alterphoneNumberError').html("");
							$('#errorlandmark').html("");
							$('#addressError').html("");
							$('#errorPincode').html("");
						});
				}	
			});	
		}
}

function requestServiceValidations(){
	var flagg=true;
	var charactervalidation = /^[a-zA-Z\s]*$/;
	var insurance=$('#insurance').val();
	var phone=$('#phone').val();
	var alterphone=$('#alterPhone').val();
	var address=$('#address').val();
	var landmark=$('#landmark').val();
	var pincode=$('#pincode').val();
	var type=$('#hid_value').val();
	/*if($('#Testname').val()==null){
		$('#errortestname').html(Request_service_selcttest);
		flagg=false;
	}else if($('#Testname').val()=="0"){
		$('#errortestname').html(Request_service_selcttest);
		flagg=false;
	}else{
		$('#errortestname').html('');
	}*/
	if(!$('#insurenceyes').is(':checked')){
		if(typeof $('input[name=insurenceyes]:checked').val()=="undefined"){
			$('#insurenceyesError').html(Request_service_insurence);
			flagg=false;
		}else{
			$('#insurenceyesError').html('');
		}
	}else{
		$('#insurenceyesError').html('');
	}
	if($('input[name=insurenceyes]:checked').val()==1){
		if(insurance=="0"){
		$('#errorInsurance').html(Request_service_insurence);
		flagg=false;
		}else{
			$('#errorInsurance').html('');
		}
		if(insurance=='Others'){
			if($('#pnumber').val()==""){
				$('#pnumberError').html(Request_service_policy_num);
				flagg=false;
			}else if(isNaN($('#pnumber').val())){
				$('#pnumberError').html(Request_service_char_validation_message);
				flagg=false;
			}else{
				$('#pnumberError').html('');
			}
			if($('#policyhname').val()==""){
				$('#policyhnameError').html(Request_service_policyhoder_name);
				flagg=false;
			}else if(!$('#policyhname').val().match(charactervalidation)){
				$('#policyhnameError').html(Request_service_chr_validation_message);
				flagg=false;
			}else{
				$('#policyhnameError').html('');
			}if($('#dependent').val()==""){
				$('#errordependent').html(Request_service_uit_dependent);
				flagg=false;
			}else{
				$('#errordependent').html('');
			}
		}	
	}
		if(phone==""){
			$('#phoneNumberError').html(Account_page_phonenumber);
			flagg=false;
		}else if(isNaN(phone)){
			  $('#phoneNumberError').html(Account_page_numbervalidation);
			  flagg=false;
		}else{
			$('#phoneNumberError').html('');
		}
		if(alterphone==""){
			$('#alterphoneNumberError').html(Request_aleter_phone);
			flagg=false;
		}else if(isNaN(phone)){
			  $('#alterphoneNumberError').html(Account_page_numbervalidation);
			  flagg=false;
		}else{
			$('#alterphoneNumberError').html('');
		}
		if(landmark==""){
			$('#errorlandmark').html(Account_page_location );
			flagg=false;
		}else{
			$('#errorlandmark').html('');
		}
		if(address==""){
			$('#addressError').html(Account_page_address);
			flagg=false;
		}else{
			$('#addressError').html('');
		}
		if(pincode==""){
			$('#errorPincode').html(Account_page_pincode);
			flagg=false;
		}else if(isNaN(pincode)){
		   $("#errorPincode").html(Register_page_numbervalidation);
		   flagg=false;
		}else{
			$('#errorPincode').html('');
		}
	if(flagg==true){
		$('#requestServiceReload').html('<img src="images/ajax-loader.gif"/>');
		$.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'nursing-services',
			dataType	: 	"json",
			data		:	$('#requestServices').serialize(),
			success: function(data){
				$('#requestServiceReload').html('');
				$("#serviceSuccusses").val('');
				if(data.value==1){
					$('#success_alert').show();
					$("#serviceSuccusses").html(Request_service_success_message);
					$("html, body").animate({ scrollTop: 0 }, 600);
					$('#success_alert').delay(3000).fadeOut('slow');
					$('#error_alert').hide();
				}
			}
		});
	}       
}
function pageselectCallbackOrder(page_index, jq){
	var items_per_page = $('#items_per_page').val();
	var max_elem = Math.min((page_index+1) * items_per_page, members.length);
	var pagei=page_index*items_per_page;
	var count=0;var html="";var phtml="";
	var auto_renewal='';
	var each_days='';
	var status='';
	var delivered_date='';
	var action='';				
	var viewDetailes='';				
	var immidiate='';				
	var deliverdDate='';				
	var viewAll="";
	var imagees="";
	var images="";
	var viewallImages="";
	html+='<table class="table table-bordered">'+
				'<tr class="table_th_bg">'+
				'<th>Send Date</th>'+
				'<th>Prescription</th>'+
				'<th>Attachment</th>'+
				'<th>Status</th>'+
				'<th>Action</th>'+
			'</tr>';
	var obj = eval(members);
	$.each(obj, function (index,Object) {
	if(pagei==index){
	if(pagei<max_elem){
		if(Object.prescription_upload_path!=""){
			var imagess=Object.prescription_upload_path;
			images=imagess.split('**');
			if(images.length>0){
			  for(var i=0;i<1;i++){
				   if(images[i]!=null){
						imagees+='<p><img src="'+uploadImgUrl+images[i]+'" width="100px" height="100px"/></p>';
						if(images.length>1){
							imagees+='<a href="#image'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">ViewAll</a>'
						}
					}else{
						imagees+='<p><img src="'+uploadImgUrl+'default.jpg" width="100px" height="100px"/></p>';
					}
				}
			}
		}else{
			imagees+='<p><img src="'+uploadImgUrl+'default.jpg" width="100px" height="100px"/></p>';
		}
		var pdetails=Object.prescription_details;
		var details=pdetails.split('**');
		if(details.length>0){
		  for(var i=0;i<=1;i++){
			   if(typeof details[i]!='undefined'){
				var names=details[i].split('$$');
				phtml+='Tabletname:'+names[0]+'<br/> Quantity:'+names[1]+'<br/>';
				}
			}
			if(details.length>2){
			  phtml+='<a href="#viewall'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">ViewAll</a>';
			}
		}
		if(Object.auto_renewal==0 || Object.auto_renewal==null){
			auto_renewal='No';
		}else{
			auto_renewal='Yes';
		}
		if(Object.each_days==0 || Object.auto_renewal==null){
			each_days='No';
		}else{
			each_days=Object.each_days;
		}
		if(Object.status==0){
			status='Pending';
			if(Object.auto_renewal==0 || Object.auto_renewal==null){
				action='<a href="javascript:void(0)" onclick="reOrderDetailes('+Object.user_medicine_order_id+')">ReOrder</a>'+'/'+'<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a>';
			}else{
				 action='<a href="javascript:void(0)" onclick="cancelOrder('+Object.user_medicine_order_id+')">Cancel Order</a>'+'/'+'<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a>';
			}
		}else if(Object.status==1){
			status='Proccessing';
			if(Object.auto_renewal==0 || Object.auto_renewal==null){
				action='<a href="javascript:void(0)" onclick="reOrderDetailes('+Object.user_medicine_order_id+')">ReOrder</a>'+'/'+'<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a>';
			}else{
				action='<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a>';
			}
		}else if(Object.status==2){
			status='Processed ';
			if(Object.auto_renewal==0  || Object.auto_renewal==null){
				action='<a href="javascript:void(0)" onclick="reOrderDetailes('+Object.user_medicine_order_id+')" >ReOrder</a>'+'/'+'<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a>';
			}else{
				action='<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a>';
			}
		}else if(Object.status==3){
			status='Cancelled';
			if(Object.auto_renewal==0 || Object.auto_renewal==null){
				action='<a href="javascript:void(0)" onclick="reOrderDetailes('+Object.user_medicine_order_id+')">ReOrder</a>'+'/'+'<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a>';
			}else{
				action='<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a>';
			}
		}
		if(Object.delivered_date=="" || Object.delivered_date==null){
			delivered_date="Not delivered";
		}else{
			delivered_date=Object.delivered_date;
		}
		if(Object.immediate==0 || Object.immediate==null){
			immidiate='Not Immidiate';
		}else{
			immidiate='Yes';
		}
		if(Object.delivered_date==null){
			var deliverdDate="Not Delivered ";
		}else{
			deliverdDate=Object.delivered_date;
		}
		count++;
		viewDetailes+='<div id="'+Object.user_medicine_order_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Order Detailes</h3></div><div id="popup" class="modal-body">'+
				'<table class="table table-condensed">'+
					'<tr><th>Tracking_id</th><th>'+Object.user_medicine_order_id+'</th></tr>'+
					//'<tr><th>Price</th><th>'+Object.price+'</th></tr>'+
					//'<tr><th>Discount</th><th>'+Object.discount+'</th></tr>'+
					'<tr><th>Auto Renewal </th><th>'+auto_renewal+'</th></tr>'+
					'<tr><th>Days</th><th>'+each_days+'</th></tr>'+
					'<tr><th>Delivered Date</th><th>'+deliverdDate+'</th></tr>'+
					'<tr><th>Landmark </th><th>'+Object.landmark+'</th></tr>'+
					'<tr><th>Alternative Phonenumber</th><th>'+Object.alterphone+'</th></tr>'+
					'<tr><th>Address</th><th>'+Object.address+'</th></tr>'+
					'<tr><th>Immidiate</th><th>'+immidiate+'</th></tr>'+
					'<tr><th>AvailableTime</th><th>'+Object.availabletime+'</th></tr>'+
				'</table>'+	
			'</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
			viewAll+='<div id="viewall'+Object.user_medicine_order_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Prescription</h3></div><div id="popup" class="modal-body">'+
				'<table class="table table-condensed">';
				viewAll+='<tr><th>Tabletname</th>'+
						'<th>Quantity</th></tr>';
				if(details.length>0){
					for(var i=0;i<=(details.length-1);i++){
						var names=details[i].split('$$');
						viewAll+='<tr><th>'+names[0]+'</th>'+
						'<th>'+names[1]+'</th></tr>';
					}
				}
				viewAll+='</table>'+	
			'</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
			viewallImages+='<div id="image'+Object.user_medicine_order_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Images</h3></div><div id="popup" class="modal-body">';
			viewallImages+='<div id="myCarousel'+Object.user_medicine_order_id+'" class="carousel slide">'+
			'<ol class="carousel-indicators">';
			if(images.length>0){
				for(var img=0;img<=(images.length)-1;img++){
					//if(img==0){
						viewallImages+='<li data-target="#myCarousel'+Object.user_medicine_order_id+'" data-slide-to="'+img+'" class="active"></li>';
					//}
				}
			}
			viewallImages+='</ol>'+
			'<!-- Carousel items -->'+
			'<div class="carousel-inner">';
			if(images.length>0){
				for(var img=0;img<=(images.length)-1;img++){
					if(img==0){
						viewallImages+='<div class="active item"><img width="500px;" height="500px;" src="'+uploadImgUrl+images[img]+'"></div>';
					}else{
						viewallImages+='<div class="item"><img width="500px;" height="500px;" src="'+uploadImgUrl+images[img]+'"></div>';
					}
					
				}
			}
			viewallImages+='</div>'+
			'<!-- Carousel nav -->'+
			'<a class="carousel-control left" href="#myCarousel'+Object.user_medicine_order_id+'" data-slide="prev">&lsaquo;</a>'+
			'<a class="carousel-control right" href="#myCarousel'+Object.user_medicine_order_id+'" data-slide="next">&rsaquo;</a>'+
			'</div>';
			viewallImages+='</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
			html+=	'<tr>'+
					'<td>'+Object.date_added+'</td>'+
					'<td>'+phtml+'</td>'+
					'<td>'+imagees+'</td>'+
					'<td>'+status+'</td>'+
					'<td>'+action+'</td>'+
				'</tr>';
		phtml="";
		imagees="";
		}
		pagei++;
		}
		
	});
	html+='</table>';
	$('#Searchresult').html(html);
	$('#viewDetailes_id').html(viewDetailes);				
	$('#viewall_detailes').html(viewAll);				
	$('#viewall_Imags').html(viewallImages);
	var status = getParameterByName('status');
	if(status=='cancelled'){
		$('#success_alert').show();
		$("#cancelled_order").html("Cancelled order successfully");
		$("html, body").animate({ scrollTop: 0 }, 600);
		$('#success_alert').delay(3000).fadeOut('slow');
	}
}
function pageselectCallbackRenewal(page_index, jq){
	var items_per_page = $('#items_per_page').val();
	var max_elem = Math.min((page_index+1) * items_per_page, members.length);
	var pagei=page_index*items_per_page;
	var html="";
	var phtml="";
	var auto_renewal='';
	var each_days='';
	var status='';
	var delivered_date='';
	var action='';
	var viewAll='';
	var imagees="";
	var images="";
	var view_renewal_detailes='';
	var viewallImages='';
	var count=0;
		html+='<table class="table table-bordered">'+
					'<tr class="table_th_bg">'+
					'<th>Send Date</th>'+
					'<th>Prescription</th>'+
					'<th>Attachment</th>'+
					'<th>Status</th>'+
					'<th>Action</th>'+
				'</tr>';
	var obj = eval(members);
	$.each(obj, function (index,Object) {
	if(pagei==index){
		if(pagei<max_elem){
			if(Object.prescription_upload_path!=""){
					var imagess=Object.prescription_upload_path;
					images=imagess.split('**');
					if(images.length>0){
					  for(var i=0;i<1;i++){
						   if(images[i]!=null){
								imagees+='<p><img src="'+uploadImgUrl+images[i]+'" width="100px" height="100px"/></p>';
								if(images.length>1){
									imagees+='<a href="#Renewal_image'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">ViewAll</a>'
								}
							}else{
								imagees+='<p><img src="'+uploadImgUrl+'default.jpg" width="100px" height="100px"/></p>';
							}
						}
					}else{
						imagees+='<p><img src="'+uploadImgUrl+'default.jpg" width="100px" height="100px"/></p>';
					}
				}else{
					imagees+='<p><img src="'+uploadImgUrl+'default.jpg" width="100px" height="100px"/></p>';
				}
				var pdetails=Object.prescription_details;
				var details=pdetails.split('**');
				if(details.length>0){
					  for(var i=0;i<=1;i++){
						   if(typeof details[i]!='undefined'){
							var names=details[i].split('$$');
							phtml+='Tabletname:'+names[0]+'<br/> Quantity:'+names[1]+'<br/>';
							}
						}
						if(details.length>2){
						  phtml+='<a href="#viewall'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">ViewAll</a>';
						}
					}
				if(Object.auto_renewal==0 || Object.auto_renewal==null){
					auto_renewal='No';
				}else{
					auto_renewal='Yes';
				}
				if(Object.each_days==0 || Object.auto_renewal==null){
					each_days='No';
				}else{
					each_days=Object.each_days;
				}
				if(Object.status==0){
					status='<p>Pending</p>';
					action='<p id="cancelautorenewal'+Object.user_medicine_order_id+'"><a href="javascript:void(0)" onclick="cancelautorenewalFun('+Object.user_medicine_order_id+',0)">Cancel autorenewal</a>'+'/'+'<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a></p>';
				}else if(Object.status==2){
					status='<p>Processed</p>';
					action='<p id="cancelautorenewal'+Object.user_medicine_order_id+'"><a href="javascript:void(0)" onclick="cancelautorenewalFun('+Object.user_medicine_order_id+',0)">Cancel autorenewal</a>'+'/'+'<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a></p>';
				}else if(Object.status==3){
					status='<p>Cancelled</p>';
					action='<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a>';
				}else{
					status='<p>Processing</p>';
					action='<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a>';
				}
				if(Object.delivered_date=="" || Object.delivered_date==null){
					delivered_date="Not delivered";
				}else{
					delivered_date=Object.delivered_date;
				}
				if(Object.immediate==0 || Object.immediate==null){
						immidiate='Not Immidiate';
				}else{
						immidiate='Yes';
				}
				if(Object.delivered_date==null){
						var deliverdDate="Not Delivered ";
				}else{
						deliverdDate=Object.delivered_date;
				}
					view_renewal_detailes+='<div id="'+Object.user_medicine_order_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Renewal Order Detailes</h3></div><div id="popup" class="modal-body">'+
							'<table class="table table-condensed">'+
								'<tr><th>Tracking_id</th><th>'+Object.user_medicine_order_id+'</th></tr>'+
								'<tr><th>Auto Renewal </th><th id="auto'+Object.user_medicine_order_id+'">'+auto_renewal+'</th></tr>'+
								'<tr><th>Days</th><th>'+each_days+'</th></tr>'+
								'<tr><th>Delivered Date</th><th>'+deliverdDate+'</th></tr>'+
								'<tr><th>Landmark </th><th>'+Object.landmark+'</th></tr>'+
								'<tr><th>Alternative Phonenumber</th><th>'+Object.alterphone+'</th></tr>'+
								'<tr><th>Address</th><th>'+Object.address+'</th></tr>'+
								'<tr><th>Immidiate</th><th>'+immidiate+'</th></tr>'+
								'<tr><th>AvailableTime</th><th>'+Object.availabletime+'</th></tr>'+
							'</table>'+	
						'</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
					viewAll+='<div id="viewall'+Object.user_medicine_order_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Prescription</h3></div><div id="popup" class="modal-body">'+
							'<table class="table table-condensed">';
							viewAll+='<tr><th>Tabletname</th>'+
									'<th>Quantity</th></tr>';
							if(details.length>0){
								for(var i=0;i<=(details.length-1);i++){
									var names=details[i].split('$$');
									viewAll+='<tr><th>'+names[0]+'</th>'+
									'<th>'+names[1]+'</th></tr>';
								}
							}
							viewAll+='</table>'+	
						'</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
					viewallImages+='<div id="Renewal_image'+Object.user_medicine_order_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Images</h3></div><div id="popup" class="modal-body">';
						viewallImages+='<div id="myCarousel'+Object.user_medicine_order_id+'" class="carousel slide">'+
						'<ol class="carousel-indicators">';
						if(images.length>0){
							for(var img=0;img<=(images.length)-1;img++){
								//if(img==0){
									viewallImages+='<li data-target="#myCarousel'+Object.user_medicine_order_id+'" data-slide-to="'+img+'" class="active"></li>';
								//}
							}
						}
						viewallImages+='</ol>'+
						'<!-- Carousel items -->'+
						'<div class="carousel-inner">';
						if(images.length>0){
							for(var img=0;img<=(images.length)-1;img++){
								if(img==0){
									viewallImages+='<div class="active item"><img width="500px;" height="500px;" src="'+uploadImgUrl+images[img]+'"></div>';
								}else{
									viewallImages+='<div class="item"><img width="500px;" height="500px;" src="'+uploadImgUrl+images[img]+'"></div>';
								}
								
							}
						}
						viewallImages+='</div>'+
						'<!-- Carousel nav -->'+
						'<a class="carousel-control left" href="#myCarousel'+Object.user_medicine_order_id+'" data-slide="prev">&lsaquo;</a>'+
						'<a class="carousel-control right" href="#myCarousel'+Object.user_medicine_order_id+'" data-slide="next">&rsaquo;</a>'+
						'</div>';
						viewallImages+='</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
					html+=	'<tr>'+
							'<td>'+Object.date_added+'</td>'+
							'<td>'+phtml+'</td>'+
							'<td>'+imagees+'</td>'+							
							'<td>'+status+'</td>'+
							'<td>'+action+'</td>'+
						'</tr>';
				phtml="";
				imagees="";
		}
			pagei++;
	}	
	});
		html+='</table>';
		$('#renuwalorder_detailes').html(html);
		$('#viewrenewalDetailes_id').html(view_renewal_detailes);
		$('#viewallrenewal').html(viewAll);
		$('#viewallrenewal_Images').html(viewallImages);
		var status = getParameterByName('status');
		if(status=='cancelled'){
			$('#success_alert').show();
			$("#cancelled_autorenewalorder").html("Cancelled auto renewal successfully");
			$("html, body").animate({ scrollTop: 0 }, 600);
			$('#success_alert').delay(3000).fadeOut('slow');
		}

	return false;	
}

function pageselectCallbackReview(page_index, jq){
	var items_per_page = $('#items_per_page').val();
	var max_elem = Math.min((page_index+1) * items_per_page, members.length);
	var pagei=page_index*items_per_page;
	var html="";
	var rhtml="";
	var count=0;
	var obj = eval(members);
	$.each(obj, function (index,Object) {
	if(pagei==index){
		if(pagei<max_elem){
			html+='<div class="media">';
			html+='<a class="pull-left" href="#">';
			html+='<img src="https://lh3.googleusercontent.com/uFp_tsTJboUY7kue5XAsGA=w48-c-h48" class="media-object img_profile"></a>';		  
			html+='<div class="media-body">';
			var value=Object.rating;
			for(var i=1;i<=value;i++){
				rhtml+='<img class="star" src="images/green-star.png">';
			}for(var j=i;j<=5;j++){
				rhtml+='<img class="star" src="images/gray-star.png">';
			}
			html+='<h4>'+rhtml+'</h4>';
			html+='<h4 class="media-heading">Tracking Id:'+Object.tracking_id+'</h4>';
			html+= Object.review;	 
			html+='</div>'; 
			html+='</div>';
			rhtml="";
		}
		pagei++;
	}
	});
	$("#review_list").html(html);
	return false;
}
function pageselectCallbackDiscount(page_index, jq){
	var items_per_page = $('#items_per_page').val();
	var max_elem = Math.min((page_index+1) * items_per_page, members.length);
	var pagei=page_index*items_per_page;
	var count=0;
	var dhtml="";
	var address="";
	var prescription="";
	dhtml+='<table class="table table-bordered">'+
							'<tr class="table_th_bg">'+
							'<th>Post Order Date</th>'+
							'<th>Delivered Date</th>'+
							'<th>Tracking Id</th>'+
							'<th>Price</th>'+
							'<th>Discount</th>'+
						'</tr>';
	var obj = eval(members);
	$.each(obj, function (index,Object) {
	if(pagei==index){
		if(pagei<max_elem){
			address+='<p>'+Object.address+'</p>'+'<p>Location:'+Object.location+'</p>'+
			'<p>Pincode:'+Object.pincode+'</p>'+'<p>Contact:'+Object.phone+'</p>';
			var pdetails=Object.prescription_details;
			var details=pdetails.split('**');
			for(var i=0;i<=(details.length-1);i++){
				var names=details[i].split('$$');
				prescription+='<p>Tablet Name:'+names[0]+'&nbsp;&nbsp;&nbsp;Quantity:'+names[1]+'</p>';
			}
			dhtml+=	'<tr>'+
					'<td>'+Object.added_date+'</td>'+
					'<td>'+Object.delivered_date+'</td>'+
					'<td>'+Object.user_medicine_order_id+'</td>'+
					'<td>Rs '+Object.price+'.00</td>'+
					'<td>Rs '+Object.discount+'.00</td>'+
				'</tr>';
			address="";
			prescription="";
		}
			pagei++;
	}
	});
	dhtml+='</table>';
	$('.container_form_top').html(dhtml);
	return false;
}
function pageselectCallbackComplints(page_index, jq){
	var user_name = JSON.parse(sessionStorage["user_name"]);
	var items_per_page = $('#items_per_page').val();
	var max_elem = Math.min((page_index+1) * items_per_page, members.length);
	var pagei=page_index*items_per_page;
	var chtml='';
	var count=0;
	var obj = eval(members);
	$.each(obj, function (index,Object){
	if(pagei==index){
		if(pagei<max_elem){
		//$.each(v.user, function (index,Object) {
			//if(Object.user_type_id==3){
				//var complaint_shop_name=Object.shop_name;
				//var complaint_shop_text=Object.complaint;
				chtml+='<div class="media">'+
						'<a class="pull-left" href="#">'+
							'<img src="https://lh3.googleusercontent.com/uFp_tsTJboUY7kue5XAsGA=w48-c-h48" class="media-object img_profile">'+
						'</a>'+
						'<div class="media-body">'+
							'<h4 id="shop_name_complaint" class="media-heading">'+user_name+'&nbsp;&nbsp;&nbsp;&nbsp;'+'TRACKING ID:'+Object.complaint_on_id+'</h4>'+
							'<p id="shop_name_complaint_text">'+Object.complaint+'</p>';
							//'<input type="hidden" id="hid'+Object.shop_id+'" name="hid'+Object.shop_id+'" value="'+Object.complaint_id+'">';
			//}
		//});			
		//$.each(v.complaintss, function (index,Object) {
			if(Object.reply_text!=null){
				chtml+='<div class="media">'+
					'<a class="pull-left" href="#">'+
					'<img src="https://lh3.googleusercontent.com/uFp_tsTJboUY7kue5XAsGA=w48-c-h48" class="media-object img_profile">'+
					'</a>'+
					'<div class="media-body">'+
						'<h4 class="media-heading">Replay&nbsp;&nbsp;&nbsp;TRACKING ID:'+Object.complaint_on_id+'</h4>'+
						'<p>'+Object.reply_text+'</p>';
					
						/*if(Object.user_type_id=="3"){
							chtml+='<p><a href="javascript:void(0);" class="replay_btn" onclick="replay('+Object.complaint_relpies_id+')">Replay</a></p>'+
							'<div class="media replay_comment_show" id="replay_comment'+Object.complaint_relpies_id+'" style="display:none;">'+
								'<a class="pull-left" href="#">'+
									'<img src="https://lh3.googleusercontent.com/uFp_tsTJboUY7kue5XAsGA=w48-c-h48" class="media-object img_profile">'+
								'</a>'+
								'<div class="media-body">'+
									'<textarea id="replaytext'+Object.shop_id+'" class="span10" placeholder="Add a Replay"></textarea>'+
									'<p>Replay by '+user_name+'&nbsp;&nbsp;<a href="javascript:void(0);" class="submit_comment" onclick="submitReplay('+Object.shop_id+')">Submit Comment</a></p>'+
								'</div><span style="color:red" id="errortext'+Object.shop_id+'"></span>'+
							'</div>'+
							'<div id="appendDivs'+Object.shop_id+'"></div>';
						}*/
					chtml+='</div>'+
				'</div>';
			}
		}
	pagei++;
	}
		chtml+='</div>'+'</div>';
	});
	$("#complaint_replies").html(chtml);
	return false;
}
function pageselectCallbackServices(page_index, jq){
	var items_per_page = $('#items_per_page').val();
	var max_elem = Math.min((page_index+1) * items_per_page, members.length);
	var pagei=page_index*items_per_page;
	var count=0;var html=""; var phtml="";
	var senddate='';
	var services='';
	var status='';
	var landmark='';
	var insurence='';
	var phone='';				
	html+='<table class="table table-bordered">'+
				'<tr class="table_th_bg">'+
				'<th>Send Date</th>'+
				'<th>Services</th>'+
				'<th>Insurance</th>'+
				'<th>Landmark</th>'+
				'<th>Phone</th>'+
				'<th>Status</th>'+
			'</tr>';
	var obj = eval(members);
	$.each(obj, function (index,Object){
	if(pagei==index){
		if(pagei<max_elem){
			var pdetails=Object.service_names;
					if(pdetails==""){
						phtml+='No Services';
					}else{
						var details=pdetails.split('***');
						for(var i=0;i<=(details.length-1);i++){
							var names=details[i].split('$$');
							phtml+='Test Name:'+names[0]+'<br/> Price:'+names[1]+'<br/>';
						}
					}
					if(Object.insurance_name==null){
						 insurence="No Insurence";
					}else{
						insurence=Object.insurance_name;
					}
					if(Object.status==0 || Object.status==null){
						status='Pendding';
					}else{
						status='Processed';
					}
					html+=	'<tr>'+
								'<td>'+Object.added_date+'</td>'+
								'<td>'+phtml+'</td>'+
								'<td>'+insurence+'</td>'+
								'<td>'+Object.landmark+'</td>'+
								'<td>'+Object.phone+'</td>'+
								'<td>'+status+'</td>'+
							'</tr>';
					phtml="";
		}
		pagei++;	
	}	
	});
	html+='</table>';	
	$('#requestServices').html(html);		
}					

//dressing

function OrderDressFun(){
	var user_id = JSON.parse(sessionStorage["user_id"]);
	var charactervalidation = /^[a-zA-Z\s]*$/;
	var flag=true;
	var dressname=$('#dress_name').val();
	var dressdes=$('#dressing_des').val();
	if(dressname==""){
		$('#errordress_name').html(Dress_name);
		flag=false;
	}else if(!dressname.match(charactervalidation)){
		$('#errordress_name').html(Dress_name_validation_message);
		flag=false;
	}else{
		$('#errordress_name').html("");
	}
	if(dressdes==""){
		$('#errordressing_des').html(Dress_description);
		flag=false;
	}else{
		$('#errordressing_des').html("");
	}
	if(flag==true){
		$('#userComplaintReload').html('<img src="images/ajax-loader.gif"/>');
		$.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'nursing-services',
			dataType	: 	"json",
			data		:	{user_id:user_id,dressname:dressname,dressdes:dressdes,type:1},
			success: function(data){
				if(data.value==1){
					$('#userComplaintReload').html('');
					$('#dress_name').val("");
					$('#dressing_des').val("");
					$('#success_alert').show();
					$("#SuccessMessage").html(Dress_success_message);
					$("html, body").animate({ scrollTop:0 }, 600);
					$('#success_alert').delay(3000).fadeOut('slow');
					$('#error_alert').hide();
				}
			}
		});
	}
}
//USER NOTIFICATIONS
function userNotifications(type){
	var user_id = JSON.parse(sessionStorage["user_id"]);
	$.ajax({
		type		:	'GET',
		url			:  	webServiceUrl+'notifications/'+type+'-'+user_id,
		dataType	: 	"json",
		success: function(data){
			if(data.value==1){
				var notifications="";
				var notification_type="";
				var action="";
				notifications+='<table class="table table-bordered">'+
				'<tr class="table_th_bg">'+
				'<th>Date</th>'+
				'<th>Notification</th>'+
				'<th>Type</th>'+
				'<th>Action</th>'+
				'</tr>';
				var obj = eval("(" + data.notifications + ")");
				$.each(obj, function (index,Object){
					if(Object.type=="Enabled Auto Renewal"){
						notification_type='Admin '+Object.type +' By Your RenewalOrder';
						action='<a href="javascript:void(0)" onclick="viewRenewalNotifications('+Object.order_id+',0,'+Object.user_type_id+')">VIEW</a>';
						
					}else if(Object.type=="Cancelled Auto Renewal"){
						notification_type='Admin '+Object.type +' By Your RenewalOrder';
						action='<a href="javascript:void(0)" onclick="viewRenewalNotifications('+Object.order_id+',1,'+Object.user_type_id+')">VIEW</a>';
					}else if(Object.type=="Complaint"){
						notification_type='Shop Replay By Your '+Object.type;
						action='<a href="javascript:void(0)" onclick="viewComplaintNotifications('+Object.order_id+',2,'+Object.user_type_id+')">VIEW</a>';
					}else if(Object.type=="Cancelled"){
						notification_type=' Admin '+Object.type+'By order Tracking Id '+Object.order_id;
						action='<a href="javascript:void(0)" onclick="viewCancelledNotifications('+Object.order_id+',9,'+Object.user_type_id+')">VIEW</a>';
					}else if(Object.type=="Confirmed"){
						if(Object.status==2){
							notification_type=' Processing of your order Tracking Id '+Object.order_id;
							action='<a href="javascript:void(0)" onclick="viewConfirmedNotifications('+Object.notifications_id+',12,'+Object.user_type_id+')">VIEW</a>';
						}
					}else if(Object.type=="OrderConfirmed"){
						notification_type=' Admin Confirmed By your order Tracking Id'+Object.order_id;
						action='<a href="javascript:void(0)" onclick="viewConfirmedNotifications('+Object.notifications_id+',15,'+Object.user_type_id+')">VIEW</a>';
					}
					notifications+=	'<tr>'+
						'<td>'+Object.added_date+'</td>'+
						'<td>'+notification_type+'</td>'+
						'<td>'+Object.type+'</td>'+
						'<td>'+action+'</td>'+
					'</tr>';
				});
				$('#count').html("");
				$('#notifications').html(notifications);
				
			}else{
				$('#notifications').html("Notifications Empty");
			}
		}
	});
}

function viewRenewalNotifications(orderId,ordertype,userType){
	changeNotificationStatus(orderId,1,ordertype,userType,0);
}
function viewComplaintNotifications(orderId,ordertype,userType){
	changeNotificationStatus(orderId,2,ordertype,userType,0);
}
function viewCancelledNotifications(orderId,ordertype,userType){
	changeNotificationStatus(orderId,3,ordertype,userType,0);
}
function viewConfirmedNotifications(orderId,ordertype,userType){
	changeNotificationStatus(orderId,3,ordertype,userType,3);
}
function changeNotificationStatus(orderId,type,ordertype,userType,updatetype){
	$.ajax({
		type		:	'PUT',
		url			:  	webServiceUrl+'notifications/'+orderId,
		dataType	: 	"json",
		data		:	{
							OrderType:ordertype,userType:userType,updatetype:updatetype
						},
		success: function(data){
			if(data.value==1){
				if(type==1){
					window.location="orderhistory.html";
				}else if(type==2){
					window.location="complaints.html";
				}else if(type==3){
					window.location="orderhistory.html";
				}else if(type==4){
					window.location="orderhistory.html";
				}
			}
		}
	});	
}

function getAllUserNotifications(type){
var user_id = JSON.parse(sessionStorage["user_id"]);
	$.ajax({
		type		:	'POST',
		url			:  	webServiceUrl+'notifications',
		dataType	: 	"json",
		data		:{usertype:type,user_id:user_id},
		success: function(data){
			if(data.value==1){
				var userNotifications="";
				var userNotification_type="";
				userNotifications+='<table class="table table-bordered">'+
				'<tr class="table_th_bg">'+
				'<th>Date</th>'+
				'<th>Notification</th>'+
				'<th>Type</th>'+
				'</tr>';
				var obj = eval("(" + data.noitifications + ")");
				$.each(obj, function (index,Object){
					if(Object.type=="Enabled Auto Renewal"){
						userNotification_type=Object.user_name + Object.type +' By Your RenewalOrder';
						
					}else if(Object.type=="Cancelled Auto Renewal"){
						userNotification_type=Object.user_name + Object.type +' By Your RenewalOrder';
					}else if(Object.type=="Complaint"){
						userNotification_type=' Shop Reply By Your '+Object.type;
					}else if(Object.type=="Cancelled"){
						userNotification_type=' Admin '+Object.type+'By order Tracking Id '+Object.order_id;
					}else if(Object.type=="Confirmed"){
						userNotification_type=' Processing of your order Tracking Id '+Object.order_id;
					}else if(Object.type=="OrderConfirmed"){
						userNotification_type=' Admin Confirmed By your order Tracking Id'+Object.order_id;
					}
					userNotifications+='<tr>'+
						'<td>'+Object.added_date+'</td>'+
						'<td>'+userNotification_type+'</td>'+
						'<td>'+Object.type+'</td>'+
					'</tr>';
				});
				$('#notifications').html(userNotifications);
			}else{
				$('#notifications').html("History Is Empty");
			}
		}
	});	
}